package com.ysh.product;

import com.lyw.mapper.EbProductMapper;
import com.lyw.model.EbProduct;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.math.BigDecimal;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:xml/spring-dao.xml")
public class ysh1 {
    @Autowired
    private EbProductMapper ebProductMapper;

    @Test //这里不能省略 否则运行报错
    public void whenUpdateSuccess(){
        //1.创建商品对象
        EbProduct product = new EbProduct();
        //2.给商品对象赋值 【注意】修改一般都是根据主键进行操作，所以必须商品id,
        product.setEpId(664);
        product.setEpPrice(new BigDecimal("999.9"));
        product.setEpStock(1500);
        //3.将商品对象添加到数据库并返回受影响的行数
        int result = ebProductMapper.updateByPrimaryKeySelective(product);
        System.out.println("受影响的行数为："+result);
    }

}
